<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
   
  </style>
</head>

<body>
  <div id="app">
    {{ num }}
    {{ num2 }}
    <button @click="change">点击改变计算属性</button>
  </div>
  <script src="./vue.js"></script>
  <script>
    const vm = new Vue({
      el: '#app',
      data: {
       num: 10
      },
      methods: {
        change () {
          this.num2 = 100
        }
      },
      computed:{
        /* num2(){
          return this.num*2
        } */
        num2:{
          get(){
            return this.num*2
          },
          set(val){
            console.log('我设置计算属性了',val)
            this.num = val / 2
          }
        }
      }
    })
  </script>
</body>

</html>